<?php
class Claycode_ObjectRegister
{
	/**
	* instance of the object registration class, singleton creational design pattern
	* @var Object
	* @access private static
	*/
	private static $o_instance;
	
	private $o_setVars = array();
	
	public function __construct()
	{
		//empty constructor for now
	}
	
	public function __set($s_key, $o_obj)
	{
		//prevent double instance of the registered objects
		if(!isset($this->o_setVars[$s_key])) {
			$this->o_setVars[$s_key] = $o_obj;
		}
	}
	
	public static function getInstance()
	{
		if(!isset(self::$o_instance) ||  self::$o_instance == null) {
			self::$o_instance = new Claycode_ObjectRegister();
		}
		return self::$o_instance;
	}
	
	public function __get($s_key)
	{
		return $this->o_setVars[$s_key];
	}
	
	public function __destruct()
	{
		self::$o_instance = null;
		gc_collect_cycles();
	}
}